<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/auth/templates/template.xhtml">
	<ui:define name="pageTitle">Consultar Venda</ui:define>
	<ui:define name="body">
		<f:view>

			<f:metadata>
				<f:viewParam name="venda" value="#{vendaVSBean.venda}" />
			</f:metadata>

			<h:form id="form">

				<p:growl id="messages" showDetail="true" autoUpdate="true"
					closable="true" />

				<h:panelGrid cellspacing="10px" styleClass="center">
					<f:facet name="header">Consultar Venda</f:facet>
					<h:outputText
						value="Venda ##{vendaVSBean.venda.idVenda} - Pedido de Venda ##{vendaVSBean.venda.pedidoVenda.idPedidoVenda}"
						styleClass="header3" />
					<h:panelGrid columns="2" cellspacing="10px">
						<h:outputText value="Data :" />
						<h:outputText value="#{vendaVSBean.venda.data.time}">
							<f:convertDateTime dateStyle="medium" type="date" locale="pt_BR" />
						</h:outputText>
						<h:outputText value="Cliente:" />
						<h:outputText value="#{vendaVSBean.venda.cliente.nome}"
							rendered="#{not empty vendaVSBean.venda.cliente}" />
						<h:outputText value="Não Informado"
							rendered="#{empty vendaVSBean.venda.cliente}" />
						<h:outputText value="Valor" />
						<h:outputText value="#{vendaVSBean.venda.valor}">
							<f:convertNumber currencyCode="BRL" type="currency" />
						</h:outputText>
						<h:outputText value="Desconto" />
						<h:outputText value="#{vendaVSBean.venda.desconto}">
							<f:convertNumber currencyCode="BRL" type="currency" />
						</h:outputText>
					</h:panelGrid>

					<p:dataTable id="tabela" value="#{vendaVSBean.venda.itensVenda}"
						var="itemVenda" paginator="true" rows="10"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rowsPerPageTemplate="5,10,15">
						<p:column headerText="Nº">
							<h:outputText value="#{itemVenda.idItemVenda}" />
						</p:column>
						<p:column headerText="Produto">
							<h:outputText
								value="#{itemVenda.itemPedidoVenda.itemEstoque.produto.categoria.nome} #{itemVenda.itemPedidoVenda.itemEstoque.produto.descricao}" />
						</p:column>
						<p:column headerText="Quantidade">
							<h:outputText value="#{itemVenda.itemPedidoVenda.quantidade}" />
						</p:column>
						<p:column headerText="SubTotal">
							<h:outputText value="#{itemVenda.itemPedidoVenda.subTotal}">
								<f:convertNumber currencyCode="BRL" type="currency" />
							</h:outputText>
						</p:column>
						<p:column>

							<p:commandButton
								action="estornaritemvenda?faces-redirect=true&amp;includeViewParams=true"
								title="Estornar Item Venda" icon="ui-icon-arrowreturnthick-1-w">
								<f:setPropertyActionListener value="#{itemVenda}"
									target="#{vendaVSBean.itemVendaSelecionado}" />
							</p:commandButton>

						</p:column>
					</p:dataTable>
				</h:panelGrid>
			</h:form>
		</f:view>
	</ui:define>
</ui:composition>

</html>